//
//  MyTableViewCell.m
//  UI20_礼物说
//
//  Created by 石美妮 on 16/1/5.
//  Copyright © 2016年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "MyTableViewCell.h"

@implementation MyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.img = [[UIImageView alloc] init];
        //_img.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_img];
        _img.layer.cornerRadius = 5;
        _img.clipsToBounds = YES;
        
        self.titleLabel = [[UILabel alloc] init];
       // _titleLabel.backgroundColor = [UIColor whiteColor];
        [self.img addSubview:_titleLabel];
        _titleLabel.numberOfLines = 0;
        _titleLabel.textColor = [UIColor whiteColor];
        
        self.likeImg = [[UIImageView alloc] init];
       _likeImg.backgroundColor = [UIColor blackColor];
        [self.img addSubview:_likeImg];
        _likeImg.alpha = 0.6;
        _likeImg.layer.cornerRadius = 2;
        _likeImg.clipsToBounds = YES;
        _likeImg.userInteractionEnabled = YES;
    
        self.likeLabel = [[UILabel alloc] init];
        [self.likeImg addSubview:_likeLabel];
          _likeLabel.textColor = [UIColor whiteColor];
        _likeLabel.font = [UIFont systemFontOfSize:12];
        _likeLabel.textAlignment = NSTextAlignmentCenter;
        
        self.likeBtn = [[UIButton alloc] init];
        [self.likeImg addSubview:_likeBtn];
        [_likeBtn setImage:[UIImage imageNamed:@"4"] forState:UIControlStateNormal];
        
        
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _img.frame = CGRectMake(10, 10, 355, 150);
    CGFloat h = [[self class] heightWithText:_titleLabel.text];
    _titleLabel.frame = CGRectMake(10, 110, 335, h);
    _likeImg.frame = CGRectMake(310, 0, 40, 50);
    _likeLabel.frame = CGRectMake(0, 30, 40, 20);
    _likeBtn.frame = CGRectMake(10, 10, 20, 20);
}
+ (CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake(335, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
